<template>
  <div ref="container">
    <breadcrumb :breadList="breadList" :name="name">
      <!-- <div class="handle-box" slot="handleContent">
        <div class="handle-btn">
          <a-button class="common-btn" @click="go_toOperation('create', '')">添加用户</a-button>
        </div>
        <div class="handle-btn">
          <a-button class="common-btn">导出列表</a-button>
        </div>
      </div> -->
    </breadcrumb>
    <a-card>
      <a-form @submit="handleSubmit" :form="form">
        <a-row clss="form-row" :gutter="16">
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item label="姓名" :labelCol="{lg: {span: 8}, sm: {span: 7}}" :wrapperCol="{lg: {span: 14}, sm: {span: 17} }">
              <a-input v-model="queryParam.userName" placeholder="姓名"/>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item label="身份证号" :labelCol="{lg: {span: 8}, sm: {span: 7}}" :wrapperCol="{lg: {span: 14}, sm: {span: 17} }">
              <a-input v-model="queryParam.userIdentity" rows="1" placeholder="身份证号"/>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :sm="24">
            <a-form-item label="所属项目" :labelCol="{lg: {span: 8}, sm: {span: 7}}" :wrapperCol="{lg: {span: 14}, sm: {span: 17} }">
              <a-input v-model="queryParam.possessive" rows="1" placeholder="身份证号"/>
            </a-form-item>
          </a-col>
          <a-col :lg="2" :md="12" :sm="24">
            <a-form-item label="" :colon="false">
              <a-button class="common-btn" @click="toSearch('2')">查询</a-button>
            </a-form-item>
          </a-col>
          <a-col :lg="2" :md="12" :sm="24">
            <a-form-item label="" :colon="false">
              <a-button class="common-btn" @click="$refs.advSearchModel.add('')">高级搜索</a-button>
            </a-form-item>
          </a-col>
        </a-row>
        <adv-search-model ref="advSearchModel" @closeModel="closeModel"></adv-search-model>
      </a-form>
    </a-card>
    <a-card>
      <a-table
        :columns="columns"
        :dataSource="loadData"
        bordered
        :loading="loading"
        :pagination="false">
        <template slot="operation" slot-scope="text, record">
          <p style="display:inline" @click="$refs.connectEquipmentModel.add(record)">
            <a href="javascript:;">关联设备</a>
          </p>
        </template>
      </a-table>
      <connect-equipment-model ref="connectEquipmentModel"></connect-equipment-model>
    </a-card>
  </div>
</template>

<script>
import Breadcrumb from '@/components/tools/Breadcrumb'
import connectEquipmentModel from './connectEquipmentModel'
import AdvSearchModel from './advSearchModel'
// import { getSupplierList } from '@/api/mockdata'
export default {
  name: 'SupplierManagementList',
  components: {
    Breadcrumb,
    connectEquipmentModel,
    AdvSearchModel
  },
  data () {
    return {
      name: '',
      breadList: [],
      loading: false,
      form: this.$form.createForm(this),
      // 查询参数
      queryParam: {},
      // 表头
      columns: [
        {
          title: '户主姓名（企事业单位名称）',
          width: '20%',
          dataIndex: 'userName'
        }, {
          title: '身份证号/社会统一信用代码',
          width: '20%',
          dataIndex: 'userIdentity'
        }, {
          title: '联系电话',
          width: '10%',
          dataIndex: 'userTel'
        },
        {
          title: '所属区县',
          width: '15%',
          dataIndex: 'userArea'
        }, {
          title: '地址',
          width: '15%',
          dataIndex: 'userAddress'
        },
        {
          title: '操作',
          dataIndex: 'operation',
          scopedSlots: { customRender: 'operation' }
        }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: []
    }
  },
  created () {
    this.loading = true
    this.getBreadCrumb()
    setTimeout(() => {
      this.getData('1')
    }, 1000)
  },
  methods: {
    // 面包屑处理
    getBreadCrumb () {
      this.breadList = []
      this.name = this.$route.name
      this.$route.matched.forEach(item => {
        console.log('1111', item)
        this.breadList.push(item)
      })
    },
    getData (code) {
      const data = [
        {
          userName: '马云',
          userIdentity: '0000000000000000000',
          userArea: '大中国',
          userAddress: '杭州西湖雷峰塔',
          userTel: '18899999999',
          userType: '煤改电',
          userRoom: '100000',
          acreage: '20000',
          familyBookImg: '我是一张户口本扫描件',
          identityImg: '这是我的身份证图片',
          userPhotos: ''
        }, {
          userName: '马化腾',
          userIdentity: '0000000000000000000',
          userArea: '大中国',
          userAddress: '杭州西湖雷峰塔',
          userTel: '18899999999',
          userType: '煤改电',
          userRoom: '100000',
          acreage: '20000',
          familyBookImg: '',
          identityImg: '我是一张身份证扫描件',
          userPhotos: ''
        }, {
          userName: '雷军',
          userIdentity: '0000000000000000000',
          userArea: '大中国',
          userAddress: '杭州西湖雷峰塔',
          userTel: '18899999999',
          userType: '煤改电',
          userRoom: '100000',
          acreage: '20000',
          familyBookImg: '我是一张户口本扫描件',
          identityImg: '',
          userPhotos: '美女照片请欣赏'
        }, {
          userName: '刘强东',
          userIdentity: '0000000000000000000',
          userArea: '大中国',
          userAddress: '杭州西湖雷峰塔',
          userTel: '18899999999',
          userType: '煤改电',
          userRoom: '100000',
          acreage: '20000',
          familyBookImg: '',
          identityImg: '',
          userPhotos: ''
        }, {
          userName: '陈林',
          userIdentity: '0000000000000000000',
          userArea: '大中国',
          userAddress: '杭州西湖雷峰塔',
          userTel: '18899999999',
          userType: '煤改电',
          userRoom: '100000',
          acreage: '20000',
          familyBookImg: '',
          identityImg: '',
          userPhotos: '帅哥照片请欣赏'
        }, {
          userName: '李亮',
          userIdentity: '0000000000000000000',
          userArea: '大中国',
          userAddress: '杭州西湖雷峰塔',
          userTel: '18899999999',
          userType: '煤改电',
          userRoom: '100000',
          acreage: '20000',
          familyBookImg: '',
          identityImg: '身份证扫描件，请保密',
          userPhotos: ''
        }
      ]
      if (code === '1') {
        this.loadData = data
        setTimeout(() => {
          this.loading = false
        }, 1000)
      } else {
        this.loadData = data
        setTimeout(() => {
          this.loading = false
          this.$success({
            title: '查询成功'
          })
        }, 1000)
      }
    },
    toSearch (status) {
      this.loading = true
      this.getData(status)
    },
    handleSubmit () {
      console.log('ttt')
    },
    closeModel () {
      this.getData('2')
    },
    toConnectEquipment (record) {
      this.$success({
        title: '设备关联成功'
      })
    }
  }
}

</script>

<style lang="less" scoped>
// .handle-box {
//   display: flex;
//   margin-bottom: 10px;
//   margin-left: 800px;
// }
// .handle-btn {
//   margin-left:5px;
// }
</style>
